home *** CD-ROM | disk | FTP | other *** search
- Path: earth.execpc.com!not-for-mail
- From: sdg@earth.execpc.com (Software Development Group)
- Newsgroups: comp.lang.c
- Subject: Help! C code under Win 3.11
- Date: 23 Feb 1996 09:55:44 -0600
- Organization: Exec-PC
- Message-ID: <4gko20$oha@earth.alpha.net>
- NNTP-Posting-Host: earth-le1.execpc.com
-
-
- Could someone please tell me why this C code is not working under
- Windows 3.11. It compiles, but does nothing.
-
- The following code is main.c and there's another .c that has
- a function that's called from here.
-
- Most importantly, I'd like some kind of print-handler working.
- At least that way I can see what's going on.
-
-
- Thanks for your help.
- -----
-
- static char mc_version[] = "MATLAB Compiler 1.0 infun";
- /*
- * MATLAB Compiler: 1.0
- * Date: Oct 20, 1995
- * Arguments: -e main
- * *** suppressing complex case: no complex arguments ***
- */
- #include <math.h>
- #include "matrix.h"
- #include "mcc.h"
- #include "matlab.h"
- #include <stdio.h>
- #include <windows.h>
-
- /* static array S0_ (1 x 2) real, line 7 */
- static double S0r_[] =
- {
- 4, 1,
- };
- ...clipped a number of static arrays....
-
- static Matrix S29_ = { {0}, mxFULL, mxDOUBLE, mxSTRING, 0,
- 1, 4, S29__r_, 0, -1, 0, {0} };
-
-
- static int totalcnt = 0;
- static int upperlim = 0;
- static int firsttime = 1;
- char *OutputBuffer;
-
- void WinPrint(char *text)
- {
- int cnt;
-
- if (firsttime) {
- OutputBuffer = (char *)mxCalloc(1028, 1);
- upperlim += 1028;
- firsttime = 0;
- }
-
- cnt = strlen(text);
- if (totalcnt + cnt >= upperlim) {
- char *TmpOut;
- TmpOut = (char *)mxCalloc(upperlim + 1028, 1);
- memcpy(TmpOut, OutputBuffer, upperlim);
- upperlim += 1028;
- mxFree(OutputBuffer);
- OutputBuffer = TmpOut;
- }
- strncat(OutputBuffer, text, cnt);
- }
-
-
- void WinFlush(void)
- {
- MessageBox(NULL, OutputBuffer, "output test", MB_OK);
- mxFree(OutputBuffer);
- }
-
-
- /* int*/
- /* main(int argc, char **argv)*/
- /* {*/
-
- WINAPI
- WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
- {
- #define MAXCMDTOKENS 128
- int argc = 0;
- LPSTR argv[MAXCMDTOKENS];
-
- int n; /* Integer parameter from command line. */
-
- int ci_, i_, j_;
- unsigned flags_;
- Matrix *Mplhs_[32], *Mprhs_[32];
- int nlhs_=1, nrhs_=0;
- {
- /***************** Compiler Assumptions ****************
- *
- * CM0_ complex vector/matrix temporary
- * RM0_ real vector/matrix temporary
- * S0_ <constant>
- * S1_ <constant>
- * S2_ <constant>
- * beta complex vector/matrix
- * disp <function>
- * ekp complex vector/matrix
- * fclose <function>
- * fid real vector/matrix
- * fid integer scalar => fid_1
- * fopen <function>
- * fprintf <function>
- * fscanf <function>
- * hkp complex vector/matrix
- * initprnt <function>
- * main <function being defined>
- * pk0 complex vector/matrix
- * pk1 complex vector/matrix
- * r complex vector/matrix
- * rlse <function>
- * thetakp0 complex vector/matrix
- * thetakp1 complex vector/matrix
- *******************************************************/
- Matrix fid;
- Matrix thetakp0;
- Matrix ekp;
- Matrix hkp;
- Matrix pk0;
- Matrix r;
- Matrix beta;
- Matrix thetakp1;
- Matrix pk1;
- int fid_1;
- Matrix RM0_;
- Matrix CM0_;
-
- mccRealInit(fid);
- mccComplexInit(thetakp0);
- mccComplexInit(ekp);
- mccComplexInit(hkp);
- mccComplexInit(pk0);
- mccComplexInit(r);
- mccComplexInit(beta);
- mccComplexInit(thetakp1);
- mccComplexInit(pk1);
- mccRealInit(RM0_);
- mccComplexInit(CM0_);
-
-
- mlfSetPrintHandler(WinPrint);
-
- /* fid = fopen('thetakp0.txt'); */
- mccImport(&fid, (Matrix *) mlfFopen(0, 0, &S3_, 0, 0), 1, 5);
- /* if fid == -1 disp('error opening thetakp0.txt'); end */
- RM0_.dmode = mxNUMBER;
- {
- int m_=1, n_=1, cx_ = 0;
- double t_;
- double *p_RM0_;
- int I_RM0_=1;
- double *p_fid;
- int I_fid=1;
- m_ = mcmCalcResultSize(m_, &n_, fid.m, fid.n);
- mccAllocateMatrix(&RM0_, m_, n_);
- I_RM0_ = (RM0_.m != 1 || RM0_.n != 1);
- p_RM0_ = RM0_.pr;
- I_fid = (fid.m != 1 || fid.n != 1);
- p_fid = fid.pr;
- for (j_=0; j_<n_; ++j_)
- {
- for (i_=0; i_<m_; ++i_, p_RM0_+=I_RM0_, p_fid+=I_fid)
- {
- *p_RM0_ = (((int)*p_fid) == -1);
- ;
- }
- }
- }
- RM0_.dmode = mxNUMBER;
- if (mccIfCondition(&RM0_))
- {
- (void) mlfDisp(&S4_);
- WinFlush();
- }
- /* thetakp0 = fscanf(fid,'%G',[4,1]); */
- mccImport(&thetakp0, (Matrix *) mlfFscanf(0, &fid, &S5_, &S0_), 1, 7);
- /* fclose(fid); */
- Mplhs_[0] = (Matrix *) mlfFclose(&fid);
- mccFreeMatrix(Mplhs_[0]);
-
- /* fid = fopen('ekp.txt'); */
- mccImport(&fid, (Matrix *) mlfFopen(0, 0, &S6_, 0, 0), 1, 10);
- /* if fid == -1 disp('error opening ekp.txt'); end */
- RM0_.dmode = mxNUMBER;
- {
- int m_=1, n_=1, cx_ = 0;
- double t_;
- double *p_RM0_;
- int I_RM0_=1;
- double *p_fid;
- int I_fid=1;
- m_ = mcmCalcResultSize(m_, &n_, fid.m, fid.n);
- mccAllocateMatrix(&RM0_, m_, n_);
- I_RM0_ = (RM0_.m != 1 || RM0_.n != 1);
- p_RM0_ = RM0_.pr;
- I_fid = (fid.m != 1 || fid.n != 1);
- p_fid = fid.pr;
- for (j_=0; j_<n_; ++j_)
- {
- for (i_=0; i_<m_; ++i_, p_RM0_+=I_RM0_, p_fid+=I_fid)
- {
- *p_RM0_ = (((int)*p_fid) == -1);
- ;
- }
- }
- }
- RM0_.dmode = mxNUMBER;
- if (mccIfCondition(&RM0_))
- {
- (void) mlfDisp(&S7_);
- WinFlush();
- }
- /* ekp = fscanf(fid,'%G'); */
- mccImport(&ekp, (Matrix *) mlfFscanf(0, &fid, &S8_, 0), 1, 12);
- /* fclose(fid); */
- Mplhs_[0] = (Matrix *) mlfFclose(&fid);
- mccFreeMatrix(Mplhs_[0]);
-
- /* fid = fopen('hkp.txt'); */
- mccImport(&fid, (Matrix *) mlfFopen(0, 0, &S9_, 0, 0), 1, 15);
- /* if fid == -1 disp('error opening hkp.txt'); end */
- RM0_.dmode = mxNUMBER;
- {
- int m_=1, n_=1, cx_ = 0;
- double t_;
- double *p_RM0_;
- int I_RM0_=1;
- double *p_fid;
- int I_fid=1;
- m_ = mcmCalcResultSize(m_, &n_, fid.m, fid.n);
- mccAllocateMatrix(&RM0_, m_, n_);
- I_RM0_ = (RM0_.m != 1 || RM0_.n != 1);
- p_RM0_ = RM0_.pr;
- I_fid = (fid.m != 1 || fid.n != 1);
- p_fid = fid.pr;
- for (j_=0; j_<n_; ++j_)
- {
- for (i_=0; i_<m_; ++i_, p_RM0_+=I_RM0_, p_fid+=I_fid)
- {
- *p_RM0_ = (((int)*p_fid) == -1);
- ;
- }
- }
- }
- RM0_.dmode = mxNUMBER;
- if (mccIfCondition(&RM0_))
- {
- (void) mlfDisp(&S10_);
- WinFlush();
- }
- /* hkp = fscanf(fid,'%G',[4,1]); */
- mccImport(&hkp, (Matrix *) mlfFscanf(0, &fid, &S11_, &S1_), 1, 17);
- /* fclose(fid); */
- Mplhs_[0] = (Matrix *) mlfFclose(&fid);
- mccFreeMatrix(Mplhs_[0]);
-
- /* fid = fopen('pk0.txt'); */
- mccImport(&fid, (Matrix *) mlfFopen(0, 0, &S12_, 0, 0), 1, 20);
- /* if fid == -1 disp('error opening pk0.txt'); end */
- RM0_.dmode = mxNUMBER;
- {
- int m_=1, n_=1, cx_ = 0;
- double t_;
- double *p_RM0_;
- int I_RM0_=1;
- double *p_fid;
- int I_fid=1;
- m_ = mcmCalcResultSize(m_, &n_, fid.m, fid.n);
- mccAllocateMatrix(&RM0_, m_, n_);
- I_RM0_ = (RM0_.m != 1 || RM0_.n != 1);
- p_RM0_ = RM0_.pr;
- I_fid = (fid.m != 1 || fid.n != 1);
- p_fid = fid.pr;
- for (j_=0; j_<n_; ++j_)
- {
- for (i_=0; i_<m_; ++i_, p_RM0_+=I_RM0_, p_fid+=I_fid)
- {
- *p_RM0_ = (((int)*p_fid) == -1);
- ;
- }
- }
- }
- RM0_.dmode = mxNUMBER;
- if (mccIfCondition(&RM0_))
- {
- (void) mlfDisp(&S13_);
- WinFlush();
- }
- /* pk0 = fscanf(fid,'%G',[4,4]); */
- mccImport(&pk0, (Matrix *) mlfFscanf(0, &fid, &S14_, &S2_), 1, 22);
- /* fclose(fid); */
- Mplhs_[0] = (Matrix *) mlfFclose(&fid);
- mccFreeMatrix(Mplhs_[0]);
-
- /* fid = fopen('r.txt'); */
- mccImport(&fid, (Matrix *) mlfFopen(0, 0, &S15_, 0, 0), 1, 25);
- /* if fid == -1 disp('error opening r.txt'); end */
- RM0_.dmode = mxNUMBER;
- {
- int m_=1, n_=1, cx_ = 0;
- double t_;
- double *p_RM0_;
- int I_RM0_=1;
- double *p_fid;
- int I_fid=1;
- m_ = mcmCalcResultSize(m_, &n_, fid.m, fid.n);
- mccAllocateMatrix(&RM0_, m_, n_);
- I_RM0_ = (RM0_.m != 1 || RM0_.n != 1);
- p_RM0_ = RM0_.pr;
- I_fid = (fid.m != 1 || fid.n != 1);
- p_fid = fid.pr;
- for (j_=0; j_<n_; ++j_)
- {
- for (i_=0; i_<m_; ++i_, p_RM0_+=I_RM0_, p_fid+=I_fid)
- {
- *p_RM0_ = (((int)*p_fid) == -1);
- ;
- }
- }
- }
- RM0_.dmode = mxNUMBER;
- if (mccIfCondition(&RM0_))
- {
- (void) mlfDisp(&S16_);
- WinFlush();
- }
- /* r = fscanf(fid,'%G'); */
- mccImport(&r, (Matrix *) mlfFscanf(0, &fid, &S17_, 0), 1, 27);
- /* fclose(fid); */
- Mplhs_[0] = (Matrix *) mlfFclose(&fid);
- mccFreeMatrix(Mplhs_[0]);
-
- /* fid = fopen('beta.txt'); */
- mccImport(&fid, (Matrix *) mlfFopen(0, 0, &S18_, 0, 0), 1, 30);
- /* if fid == -1 disp('error opening beta.txt'); end */
- RM0_.dmode = mxNUMBER;
- {
- int m_=1, n_=1, cx_ = 0;
- double t_;
- double *p_RM0_;
- int I_RM0_=1;
- double *p_fid;
- int I_fid=1;
- m_ = mcmCalcResultSize(m_, &n_, fid.m, fid.n);
- mccAllocateMatrix(&RM0_, m_, n_);
- I_RM0_ = (RM0_.m != 1 || RM0_.n != 1);
- p_RM0_ = RM0_.pr;
- I_fid = (fid.m != 1 || fid.n != 1);
- p_fid = fid.pr;
- for (j_=0; j_<n_; ++j_)
- {
- for (i_=0; i_<m_; ++i_, p_RM0_+=I_RM0_, p_fid+=I_fid)
- {
- *p_RM0_ = (((int)*p_fid) == -1);
- ;
- }
- }
- }
- RM0_.dmode = mxNUMBER;
- if (mccIfCondition(&RM0_))
- {
- (void) mlfDisp(&S19_);
- WinFlush();
- }
- /* beta = fscanf(fid,'%G'); */
- mccImport(&beta, (Matrix *) mlfFscanf(0, &fid, &S20_, 0), 1, 32);
- /* fclose(fid); */
- Mplhs_[0] = (Matrix *) mlfFclose(&fid);
- mccFreeMatrix(Mplhs_[0]);
-
- /* [thetakp1,pk1]=rlse(thetakp0,ekp,hkp',pk0,r,beta); */
- mccConjTrans(&CM0_, &hkp);
- mccImport(&thetakp1, (Matrix *) mlfRlse(&Mplhs_[1], &thetakp0, &ekp, &CM0_, &pk0, &r, &beta), 1, 35);
- mccImport(&pk1, Mplhs_[ 1 ], 1, 35);
-
- /* fid = fopen('thetakp1.txt','w'); */
- Mplhs_[0] = (Matrix *) mlfFopen(0, 0, &S21_, &S22_, 0);
- fid_1 = mccImportReal(0, Mplhs_[ 0 ], " (main, line 37): fid_1");
- /* if fid == -1 disp('error opening thetakp1.txt for write'); end */
- if ((fid_1 == -1))
- {
- (void) mlfDisp(&S23_);
- WinFlush();
- }
- /* fprintf(fid,'%G %G %G %G\n',thetakp1); */
- Mplhs_[0] = (Matrix *) mlfFprintf(mccTempMatrix((double)(fid_1), 0., mxNUMBER), &S24_, &thetakp1, 0);
- mccFreeMatrix(Mplhs_[0]);
- WinFlush();
- /* fclose(fid); */
- Mplhs_[0] = (Matrix *) mlfFclose(mccTempMatrix((double)(fid_1), 0., mxNUMBER));
- mccFreeMatrix(Mplhs_[0]);
-
- /* fid = fopen('pk1.txt','w'); */
- Mplhs_[0] = (Matrix *) mlfFopen(0, 0, &S25_, &S26_, 0);
- fid_1 = mccImportReal(0, Mplhs_[ 0 ], " (main, line 42): fid_1");
- /* if fid == -1 disp('error opening pk1.txt'); end */
- if ((fid_1 == -1))
- {
- (void) mlfDisp(&S27_);
- WinFlush();
- }
- /* fprintf(fid,'%G %G %G %G\n',pk1); */
- Mplhs_[0] = (Matrix *) mlfFprintf(mccTempMatrix((double)(fid_1), 0., mxNUMBER), &S28_, &pk1, 0);
- mccFreeMatrix(Mplhs_[0]);
- WinFlush();
- /* fclose(fid); */
- Mplhs_[0] = (Matrix *) mlfFclose(mccTempMatrix((double)(fid_1), 0., mxNUMBER));
- mccFreeMatrix(Mplhs_[0]);
-
- /* disp('done'); */
- (void) mlfDisp(&S29_);
- WinFlush();
- mccFreeMatrix(&fid);
- mccFreeMatrix(&thetakp0);
- mccFreeMatrix(&ekp);
- mccFreeMatrix(&hkp);
- mccFreeMatrix(&pk0);
- mccFreeMatrix(&r);
- mccFreeMatrix(&beta);
- mccFreeMatrix(&thetakp1);
- mccFreeMatrix(&pk1);
- mccFreeMatrix(&RM0_);
- mccFreeMatrix(&CM0_);
- return(0);
- WinFlush();
- }
- }
-
-